library sqflite_dev;

import 'dart:io';

import 'package:build/build.dart';
import 'package:source_gen/source_gen.dart';
import 'package:sqflite_dev/src/combine_builder.dart';
import '/src/data_class_genrator.dart';
import '/src/sqlitex_generator.dart';

Builder nativeClassBuilder(BuilderOptions options) {
  return SharedPartBuilder([SqlitexDatabaseGenerator(), DataClassNameGenerator()], "sqlite");
}

PostProcessBuilder combinePartBuilder(BuilderOptions options) => CombineBuilder();

Future buildTempFile(String content, BuildStep buildStep) {
  String name = buildStep.inputId.path.split("/").last;
  File file = File('.dart_tool/build/generated/${buildStep.inputId.package}/lib/$name.json');
  Directory directory = file.parent;
  if(!directory.existsSync()) directory.createSync(recursive: true);
  return file.writeAsString(content, mode: FileMode.append);
}

